fix(idempotency): TypeError when calling is_missing_idempotency_key with an int#315
Conversation
Fix for: TypeError: 'int' object is not iterable
heitorlessa
left a comment
There was a problem hiding this comment.
Great catch! One minor thing to break that into a multi-line statement as that would've been easier to spot this issue too.
| @staticmethod | ||
| def is_missing_idempotency_key(data) -> bool: | ||
| return data is None or not data or all(x is None for x in data) | ||
| return data is None or not data or (type(data).__name__ in ("tuple", "list") and all(x is None for x in data)) |
There was a problem hiding this comment.
Can we break this into a multi-line thing?
It's quite complex now and we might find another bug here in the future I'm sure
Codecov Report
@@ Coverage Diff @@
## develop #315 +/- ##
========================================
Coverage 99.88% 99.88%
========================================
Files 91 91
Lines 3339 3341 +2
Branches 162 163 +1
========================================
+ Hits 3335 3337 +2
Misses 2 2
Partials 2 2
Continue to review full report at Codecov.
|
heitorlessa
left a comment
There was a problem hiding this comment.
Control flow simplification with two Ifs
|
@heitorlessa funny way of doing it: assert type(None).__name__ == "NoneType" |
|
First name I actually see type(obj).__name__ tbh as opposed to instance ;)
…On Sun, 7 Mar 2021 at 09:09, Michael Brewer ***@***.***> wrote:
@heitorlessa <https://github.com/heitorlessa> funny way of doing it:
assert type(None).__name__ == "NoneType"
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#315 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBEY43RE5PTXNUQ4JC3TCMYB3ANCNFSM4YXRJGBQ>
.
|
…tools-python into develop * 'develop' of https://github.com/awslabs/aws-lambda-powertools-python: feat(logging): Include exception_name (#320) chore: remove gatsby mention as migrated completed refactor(parameters): Consistently reference env (#319) docs(metrics): remove minimum dimensions docs: Correct code examples (#317) docs(metrics): Correct code examples in markdown (#316) fix(idempotency): TypeError when calling is_missing_idempotency_key with an int (#315) docs(metrics): Corrections to the code examples (#314) fix(idempotency): Correctly handle save_inprogress errors (#313)
Description of changes:
Fix for
is_missing_idempotency_keywhich can raise aTypeError: 'int' object is not iterablefor the follow code
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.